﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using TomShane.Neoforce.Controls;
using BlackAndWhiteBalance.CustomControls;

namespace BlackAndWhiteBalance
{
    public class HUD : GameComponent
    {
        Core core;
        KeyboardState previousKeyState;
        Manager manager;

        const int hudWidth = 256;
        const int sideSpace = 5;
        const int insideContainerTopSpace = 15;
        const int insideContainerBottomSpace = 10;
        const int insideContainerLeftSpace = 5;
        const int btnWidth = 114;
        const int smallSpace = 5;

        ImageBox imgTitle;

        GroupBox SystemContainer;
        TextChangeButton btnPause;

        GroupBox timeScaleContainer;
        TrackBar timeScaleBar;
        AWPLabel lblTimeScaleValue;

        GroupBox numDotsContainer;
        TrackBar numDotsBar;
        AWPLabel lblNumDotsValue;

        Button btnReset;

        Button btnAddControl;
        TextChangeButton btnHideControls;

        GroupBox SelectedControlContainer;
        Button btnNextControl;
        AWPLabel lblControlType;
        Button btnChangeControlType;

        GroupBox controlStrengthContainer;
        TrackBar controlStrengthBar;
        AWPLabel lblControlStrengthValue;

        Button btnRemoveControl;
        TextChangeButton btnDisableControl;

        GroupBox RenderingContainer;

        GroupBox BlurContainer;
        AWPCheckBox cbxBlur;
        TrackBar BlurBar;
        AWPLabel lblBlurValue;

        GroupBox BlackWhiteContainer;
        AWPCheckBox cbxBlackWhite;
        TrackBar BlackWhiteBar;
        AWPLabel lblBlackWhiteValue;

        AWPCheckBox cbxFullScreen;

        public HUD(Core core)
            : base(core)
        {
            this.core = core;
            this.manager = core.GUIManager;
            previousKeyState = Keyboard.GetState();

            imgTitle = new ImageBox(manager);
            imgTitle.Init();
            manager.Add(imgTitle);
            imgTitle.Top = 0;
            imgTitle.Left = 0;
            imgTitle.Image = core.Content.Load<Texture2D>(@"TitleImage");
            imgTitle.Width = imgTitle.Image.Width;
            imgTitle.Height = imgTitle.Image.Height;
            imgTitle.CanFocus = false;
            imgTitle.StayOnBack = true;
            imgTitle.Passive = true;

            #region System

            SystemContainer = new GroupBox(manager);
            SystemContainer.Init();
            manager.Add(SystemContainer);
            SystemContainer.Text = "System";
            SystemContainer.Top = 121;
            SystemContainer.Left = sideSpace;
            SystemContainer.Width = hudWidth - sideSpace * 2;

            cbxFullScreen = new AWPCheckBox(manager);
            cbxFullScreen.Init();
            cbxFullScreen.Parent = SystemContainer;
            cbxFullScreen.Width = btnWidth;
            cbxFullScreen.Text = "Full Screen";
            cbxFullScreen.Left = insideContainerLeftSpace;
            cbxFullScreen.Top = insideContainerTopSpace;
            cbxFullScreen.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(cbxFullScreen_CheckedChanged);

            #region Time Scale Control:

            timeScaleContainer = new GroupBox(manager);
            timeScaleContainer.Init();
            timeScaleContainer.Parent = SystemContainer;
            timeScaleContainer.Left = insideContainerLeftSpace;
            timeScaleContainer.Top = cbxFullScreen.Top + cbxFullScreen.Height + smallSpace;
            timeScaleContainer.Width = timeScaleContainer.Parent.ClientWidth - sideSpace * 2;
            timeScaleContainer.Text = "Time Scale";

            timeScaleBar = new TrackBar(manager);
            timeScaleBar.Init();
            timeScaleBar.Parent = timeScaleContainer;
            timeScaleBar.Width = timeScaleBar.Parent.ClientWidth - sideSpace *2;
            timeScaleBar.Left = insideContainerLeftSpace;
            timeScaleBar.Top = insideContainerTopSpace;
            timeScaleBar.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(timeScaleBar_ValueChanged);
            timeScaleBar.Range = 1000;

            lblTimeScaleValue = new AWPLabel(manager);
            lblTimeScaleValue.Init();
            lblTimeScaleValue.Parent = timeScaleContainer;
            lblTimeScaleValue.Width = timeScaleBar.Width;
            lblTimeScaleValue.Top = timeScaleBar.Top + timeScaleBar.Height;
            lblTimeScaleValue.Left = timeScaleBar.Left;
            lblTimeScaleValue.Alignment = Alignment.TopRight;
            timeScaleBar.Value = 100;

            timeScaleContainer.Height = lblTimeScaleValue.Top + lblTimeScaleValue.Height + insideContainerBottomSpace;

            #endregion

            #region Number of Dots Control:

            numDotsContainer = new GroupBox(manager);
            numDotsContainer.Init();
            numDotsContainer.Parent = SystemContainer;
            numDotsContainer.Left = insideContainerLeftSpace;
            numDotsContainer.Top = timeScaleContainer.Top + timeScaleContainer.Height + smallSpace;
            numDotsContainer.Width = numDotsContainer.Parent.ClientWidth - sideSpace * 2;
            numDotsContainer.Text = "Number of Dots";

            numDotsBar = new TrackBar(manager);
            numDotsBar.Init();
            numDotsBar.Parent = numDotsContainer;
            numDotsBar.Width = numDotsBar.Parent.ClientWidth - sideSpace * 2;
            numDotsBar.Left = insideContainerLeftSpace;
            numDotsBar.Top = insideContainerTopSpace;
            numDotsBar.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(numDotsBar_ValueChanged);
            numDotsBar.Range = DotSystem.MaxDots;

            lblNumDotsValue = new AWPLabel(manager);
            lblNumDotsValue.Init();
            lblNumDotsValue.Parent = numDotsContainer;
            lblNumDotsValue.Width = numDotsBar.Width;
            lblNumDotsValue.Top = numDotsBar.Top + numDotsBar.Height;
            lblNumDotsValue.Left = numDotsBar.Left;
            lblNumDotsValue.Alignment = Alignment.TopRight;
            numDotsBar.Value = DotSystem.numDots;

            numDotsContainer.Height = lblNumDotsValue.Top + lblNumDotsValue.Height + insideContainerBottomSpace;

            #endregion

            btnPause = new TextChangeButton(manager, "Pause [P]", "Resume [P]");
            btnPause.Init();
            btnPause.Parent = SystemContainer;
            btnPause.Top = numDotsContainer.Top + numDotsContainer.Height + smallSpace;
            btnPause.Left = insideContainerLeftSpace;
            btnPause.Width = btnWidth;
            btnPause.Click += new TomShane.Neoforce.Controls.EventHandler(btnPause_Click);

            btnReset = new Button(manager);
            btnReset.Init();
            btnReset.Parent = SystemContainer;
            btnReset.Width = btnWidth;
            btnReset.Left = btnPause.Left + btnPause.Width + smallSpace;
            btnReset.Top = btnPause.Top;
            btnReset.Text = "Reset Dots [R]";
            btnReset.Click += new TomShane.Neoforce.Controls.EventHandler(btnReset_Click);

            btnAddControl = new Button(manager);
            btnAddControl.Init();
            btnAddControl.Parent = SystemContainer;
            btnAddControl.Width = btnWidth;
            btnAddControl.Top = btnReset.Top + btnReset.Height + smallSpace;
            btnAddControl.Left = insideContainerLeftSpace;
            btnAddControl.Text = "Add Control [A]";
            btnAddControl.Click += new TomShane.Neoforce.Controls.EventHandler(btnAddControl_Click);

            btnHideControls = new TextChangeButton(manager, "Hide Controls [H]", "Show Controls [H]");
            btnHideControls.Init();
            btnHideControls.Parent = SystemContainer;
            btnHideControls.Top = btnAddControl.Top;
            btnHideControls.Left = btnAddControl.Left + btnAddControl.Width + smallSpace;
            btnHideControls.Width = btnWidth;
            btnHideControls.Click += new TomShane.Neoforce.Controls.EventHandler(btnHideControls_Click);

            SystemContainer.Height = btnAddControl.Top + btnAddControl.Height + insideContainerBottomSpace;

            #endregion


            #region Selected Control

            SelectedControlContainer = new GroupBox(manager);
            SelectedControlContainer.Init();
            manager.Add(SelectedControlContainer);
            SelectedControlContainer.Text = "Selected Control";
            SelectedControlContainer.Top = SystemContainer.Top + SystemContainer.Height + smallSpace*4;
            SelectedControlContainer.Left = sideSpace;
            SelectedControlContainer.Width = hudWidth - sideSpace * 2;

            btnNextControl = new Button(manager);
            btnNextControl.Init();
            btnNextControl.Parent = SelectedControlContainer;
            btnNextControl.Width = btnWidth;
            btnNextControl.Top = insideContainerTopSpace;
            btnNextControl.Left = insideContainerLeftSpace;
            btnNextControl.Text = "Grab Next [N]";
            btnNextControl.Click += new TomShane.Neoforce.Controls.EventHandler(btnNextControl_Click);

            btnChangeControlType = new Button(manager);
            btnChangeControlType.Init();
            btnChangeControlType.Parent = SelectedControlContainer;
            btnChangeControlType.Top = btnNextControl.Top;
            btnChangeControlType.Width = btnWidth;
            btnChangeControlType.Left = btnNextControl.Left + btnNextControl.Width + smallSpace;
            btnChangeControlType.Text = "Change Type [T]";
            btnChangeControlType.Click += new TomShane.Neoforce.Controls.EventHandler(btnChangeControlType_Click);

            lblControlType = new AWPLabel(manager);
            lblControlType.Init();
            lblControlType.Parent = SelectedControlContainer;
            lblControlType.Top = btnNextControl.Top + btnNextControl.Height + smallSpace;
            lblControlType.Left = btnChangeControlType.Left + smallSpace;
            lblControlType.Width = lblControlType.Parent.ClientWidth - lblControlType.Left;
            lblControlType.Text = "Type: Attractive";

            #region Strength

            controlStrengthContainer = new GroupBox(manager);
            controlStrengthContainer.Init();
            controlStrengthContainer.Parent = SelectedControlContainer;
            controlStrengthContainer.Left = insideContainerLeftSpace;
            controlStrengthContainer.Top = lblControlType.Top + lblControlType.Height + smallSpace;
            controlStrengthContainer.Width = controlStrengthContainer.Parent.ClientWidth - sideSpace * 2;
            controlStrengthContainer.Text = "Control Strength";

            controlStrengthBar = new TrackBar(manager);
            controlStrengthBar.Init();
            controlStrengthBar.Parent = controlStrengthContainer;
            controlStrengthBar.Width = controlStrengthBar.Parent.ClientWidth - sideSpace * 2;
            controlStrengthBar.Left = insideContainerLeftSpace;
            controlStrengthBar.Top = insideContainerTopSpace;
            controlStrengthBar.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(controlStrengthBar_ValueChanged);
            controlStrengthBar.Range = 1000;

            lblControlStrengthValue = new AWPLabel(manager);
            lblControlStrengthValue.Init();
            lblControlStrengthValue.Parent = controlStrengthContainer;
            lblControlStrengthValue.Width = controlStrengthBar.Width;
            lblControlStrengthValue.Top = controlStrengthBar.Top + controlStrengthBar.Height;
            lblControlStrengthValue.Left = controlStrengthBar.Left;
            lblControlStrengthValue.Alignment = Alignment.TopRight;
            controlStrengthBar.Value = 100;

            controlStrengthContainer.Height = lblControlStrengthValue.Top + lblControlStrengthValue.Height + insideContainerBottomSpace;

            #endregion

            btnRemoveControl = new Button(manager);
            btnRemoveControl.Init();
            btnRemoveControl.Parent = SelectedControlContainer;
            btnRemoveControl.Top = controlStrengthContainer.Top + controlStrengthContainer.Height + smallSpace*2;
            btnRemoveControl.Width = btnWidth;
            btnRemoveControl.Left = insideContainerLeftSpace;
            btnRemoveControl.Text = "Remove [Delete]";
            btnRemoveControl.Click += new TomShane.Neoforce.Controls.EventHandler(btnRemoveControl_Click);

            btnDisableControl = new TextChangeButton(manager, "Disable [D]", "Enable [D]");
            btnDisableControl.Init();
            btnDisableControl.Parent = SelectedControlContainer;
            btnDisableControl.Top = btnRemoveControl.Top;
            btnDisableControl.Width = btnWidth;
            btnDisableControl.Left = btnRemoveControl.Left + btnRemoveControl.Width + smallSpace;
            btnDisableControl.Click += new TomShane.Neoforce.Controls.EventHandler(btnDisableControl_Click);

            SelectedControlContainer.Height = btnRemoveControl.Top + btnRemoveControl.Height + insideContainerBottomSpace;

            #endregion


            #region Rendering

            RenderingContainer = new GroupBox(manager);
            RenderingContainer.Init();
            manager.Add(RenderingContainer);
            RenderingContainer.Text = "Rendering Options";
            RenderingContainer.Top = SelectedControlContainer.Top + SelectedControlContainer.Height + smallSpace * 4;
            RenderingContainer.Left = sideSpace;
            RenderingContainer.Width = hudWidth - sideSpace * 2;

            #region Blur

            BlurContainer = new GroupBox(manager);
            BlurContainer.Init();
            BlurContainer.Parent = RenderingContainer;
            BlurContainer.Left = insideContainerLeftSpace;
            BlurContainer.Top = insideContainerTopSpace;
            BlurContainer.Width = BlurContainer.Parent.ClientWidth - sideSpace * 2;
            BlurContainer.Text = "Blur";

            cbxBlur = new AWPCheckBox(manager);
            cbxBlur.Init();
            cbxBlur.Parent = BlurContainer;
            cbxBlur.Left = insideContainerLeftSpace;
            cbxBlur.Top = insideContainerTopSpace;
            cbxBlur.Width = cbxBlur.Parent.ClientWidth - insideContainerLeftSpace;
            cbxBlur.Text = "Enable [B]";
            cbxBlur.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(cbxBlur_CheckedChanged);

            BlurBar = new TrackBar(manager);
            BlurBar.Init();
            BlurBar.Parent = BlurContainer;
            BlurBar.Width = BlurBar.Parent.ClientWidth - sideSpace * 2;
            BlurBar.Left = insideContainerLeftSpace;
            BlurBar.Top = cbxBlur.Top + cbxBlur.Height + smallSpace;
            BlurBar.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(BlurBar_ValueChanged);
            BlurBar.Range = 1000;

            lblBlurValue = new AWPLabel(manager);
            lblBlurValue.Init();
            lblBlurValue.Parent = BlurContainer;
            lblBlurValue.Width = BlurBar.Width;
            lblBlurValue.Top = BlurBar.Top + BlurBar.Height;
            lblBlurValue.Left = BlurBar.Left;
            lblBlurValue.Alignment = Alignment.TopRight;
            BlurBar.Value = 100;

            BlurContainer.Height = lblBlurValue.Top + lblBlurValue.Height + insideContainerBottomSpace;

            #endregion

            #region Black and White Mode

            BlackWhiteContainer = new GroupBox(manager);
            BlackWhiteContainer.Init();
            BlackWhiteContainer.Parent = RenderingContainer;
            BlackWhiteContainer.Left = insideContainerLeftSpace;
            BlackWhiteContainer.Top = BlurContainer.Top + BlurContainer.Height + smallSpace;
            BlackWhiteContainer.Width = BlackWhiteContainer.Parent.ClientWidth - sideSpace * 2;
            BlackWhiteContainer.Text = "Black and White Mode";

            cbxBlackWhite = new AWPCheckBox(manager);
            cbxBlackWhite.Init();
            cbxBlackWhite.Parent = BlackWhiteContainer;
            cbxBlackWhite.Left = insideContainerLeftSpace;
            cbxBlackWhite.Top = insideContainerTopSpace;
            cbxBlackWhite.Width = cbxBlackWhite.Parent.ClientWidth - insideContainerLeftSpace;
            cbxBlackWhite.Text = "Enable [W]";
            cbxBlackWhite.CheckedChanged += new TomShane.Neoforce.Controls.EventHandler(cbxBlackWhite_CheckedChanged);

            BlackWhiteBar = new TrackBar(manager);
            BlackWhiteBar.Init();
            BlackWhiteBar.Parent = BlackWhiteContainer;
            BlackWhiteBar.Width = BlackWhiteBar.Parent.ClientWidth - sideSpace * 2;
            BlackWhiteBar.Left = insideContainerLeftSpace;
            BlackWhiteBar.Top = cbxBlackWhite.Top + cbxBlackWhite.Height + smallSpace;
            BlackWhiteBar.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(BlackWhiteBar_ValueChanged);
            BlackWhiteBar.Range = 99;

            lblBlackWhiteValue = new AWPLabel(manager);
            lblBlackWhiteValue.Init();
            lblBlackWhiteValue.Parent = BlackWhiteContainer;
            lblBlackWhiteValue.Width = BlackWhiteBar.Width;
            lblBlackWhiteValue.Top = BlackWhiteBar.Top + BlackWhiteBar.Height;
            lblBlackWhiteValue.Left = BlackWhiteBar.Left;
            lblBlackWhiteValue.Alignment = Alignment.TopRight;
            BlackWhiteBar.Value = 50;

            BlackWhiteContainer.Height = lblBlackWhiteValue.Top + lblBlackWhiteValue.Height + insideContainerBottomSpace;

            #endregion

            RenderingContainer.Height = BlackWhiteContainer.Top + BlackWhiteContainer.Height + insideContainerBottomSpace;

            #endregion
        }

        void cbxFullScreen_CheckedChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.Graphics.ToggleFullScreen();
        }

        void BlackWhiteBar_ValueChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            lblBlackWhiteValue.Text = ((float)BlackWhiteBar.Value / 100f).ToString() + "/" + ((float)BlackWhiteBar.Range / 100f).ToString();
            core.BlackAndWhiteThreshold = (float)BlackWhiteBar.Value / 100f;
        }

        void cbxBlackWhite_CheckedChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.BlackAndWhiteEnabled = cbxBlackWhite.Checked;
        }

        void BlurBar_ValueChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            lblBlurValue.Text = ((float)BlurBar.Value / 100f).ToString() + "/" + ((float)BlurBar.Range / 100f).ToString();
            float value = (float)BlurBar.Value / 100f;
            if(value == 0f)
                value = 0.01f;
            core.BlurAmount = value;
        }

        void cbxBlur_CheckedChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.BlurEnabled = cbxBlur.Checked;
        }

        void btnNextControl_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.GrabNextControlInList();
        }

        void btnRemoveControl_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.RemoveControl(core.CurrentControl);
        }

        void btnDisableControl_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.Controls[core.CurrentControl].Enabled = !core.Controls[core.CurrentControl].Enabled;
        }

        void btnHideControls_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.ToggleControlVisibility();
        }

        void btnAddControl_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.AddControl();
        }

        void btnReset_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.RandomizeDots();
        }

        void btnPause_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            core.IsPaused = !core.IsPaused;
        }

        void btnChangeControlType_Click(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            switch (core.Controls[core.CurrentControl].Type)
            {
                case Control.ControlType.Attractive:
                    core.Controls[core.CurrentControl].Type = Control.ControlType.Repulsive;
                    break;
                case Control.ControlType.Repulsive:
                    core.Controls[core.CurrentControl].Type = Control.ControlType.PushDown;
                    break;
                case Control.ControlType.PushDown:
                    core.Controls[core.CurrentControl].Type = Control.ControlType.PushUp;
                    break;
                case Control.ControlType.PushUp:
                    core.Controls[core.CurrentControl].Type = Control.ControlType.Attractive;
                    break;
            }
            SetupControlTypeText();
        }

        private void SetupControlTypeText()
        {
            switch (core.Controls[core.CurrentControl].Type)
            {
                case Control.ControlType.Attractive:
                    lblControlType.Text = "Type: Attractive";
                    break;
                case Control.ControlType.Repulsive:
                    lblControlType.Text = "Type: Repulsive";
                    break;
                case Control.ControlType.PushDown:
                    lblControlType.Text = "Type: PushDown";
                    break;
                case Control.ControlType.PushUp:
                    lblControlType.Text = "Type: PushUp";
                    break;
            }
        }

        void controlStrengthBar_ValueChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            lblControlStrengthValue.Text = ((float)controlStrengthBar.Value / 100f).ToString() + "/" + ((float)controlStrengthBar.Range / 100f).ToString();
            core.Controls[core.CurrentControl].strength = (float)controlStrengthBar.Value / 100f;
        }

        void numDotsBar_ValueChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            lblNumDotsValue.Text = numDotsBar.Value.ToString() + "/" + numDotsBar.Range.ToString();
            DotSystem.NumDots = numDotsBar.Value;
        }

        void timeScaleBar_ValueChanged(object sender, TomShane.Neoforce.Controls.EventArgs e)
        {
            lblTimeScaleValue.Text = ((float)timeScaleBar.Value / 100f).ToString() + "/" + ((float)timeScaleBar.Range / 100f).ToString();
            core.TimeScale = (float)timeScaleBar.Value / 100f;
        }

        internal void SetupCurrentControl(int currentControl)
        {
            controlStrengthBar.Value = (int)core.Controls[currentControl].strength * 100;
            SetupControlTypeText();
            btnDisableControl.IsFirstText = core.Controls[core.CurrentControl].Enabled;
        }

        public override void Update(GameTime gameTime)
        {
//Pause (P)
//Reset Dots (R)
//Add Control (A)
//Hide Controls (H)
//Grab Next Control (N)
//Change Type (T)
//Remove Control (Delete)
//Disable Control (D)
//Blur (B)
//Black and White (W)

            KeyboardState currentKeyState = Keyboard.GetState();

            if (previousKeyState.IsKeyDown(Keys.P) && currentKeyState.IsKeyUp(Keys.P))
            {
                btnPause.IsFirstText = !btnPause.IsFirstText;
                btnPause_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.R) && currentKeyState.IsKeyUp(Keys.R))
            {
                btnReset_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.A) && currentKeyState.IsKeyUp(Keys.A))
            {
                btnAddControl_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.H) && currentKeyState.IsKeyUp(Keys.H))
            {
                btnHideControls.IsFirstText = !btnHideControls.IsFirstText;
                btnHideControls_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.N) && currentKeyState.IsKeyUp(Keys.N))
            {
                btnNextControl_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.T) && currentKeyState.IsKeyUp(Keys.T))
            {
                btnChangeControlType_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.Delete) && currentKeyState.IsKeyUp(Keys.Delete) || previousKeyState.IsKeyDown(Keys.Back) && currentKeyState.IsKeyUp(Keys.Back))
            {
                btnRemoveControl_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.D) && currentKeyState.IsKeyUp(Keys.D))
            {
                btnDisableControl.IsFirstText = !btnDisableControl.IsFirstText;
                btnDisableControl_Click(this, new TomShane.Neoforce.Controls.EventArgs());
            }
            if (previousKeyState.IsKeyDown(Keys.B) && currentKeyState.IsKeyUp(Keys.B))
            {
                cbxBlur.Checked = !cbxBlur.Checked;
            }
            if (previousKeyState.IsKeyDown(Keys.W) && currentKeyState.IsKeyUp(Keys.W))
            {
                cbxBlackWhite.Checked = !cbxBlackWhite.Checked;
            }

            previousKeyState = currentKeyState;

            base.Update(gameTime);
        }
    }
}
